from django.db import models
from movies.models import TicketSeat, FilmSchedule
from django.contrib.auth import get_user_model
from uuid import uuid4

User = get_user_model()


# Create your models here.

class MovieOrders(models.Model):
    STATUS = (
        ('1', '待支付'),
        ('2', '支付成功'),
        ('3', '退款成功')
    )
    price = models.FloatField(verbose_name='订单的价格')
    seats = models.ManyToManyField(TicketSeat, verbose_name='订单对应的座位')
    add_time = models.DateTimeField(auto_now_add=TicketSeat, verbose_name='订单创建的时间')
    film_schedule = models.ForeignKey(FilmSchedule, verbose_name='订单对应的影厅')
    user = models.ForeignKey(User, verbose_name='订单所属的用户')
    # 代替我们的主键
    order_num = models.UUIDField(max_length=100, default=uuid4, verbose_name='流水号')
    pay_num = models.CharField(max_length=100, default="", verbose_name='第三方平台支付订单号')
    status = models.CharField(max_length=2, choices=STATUS, verbose_name='支付状态', default='1')

    class Meta:
        verbose_name = '订单信息'
        verbose_name_plural = verbose_name
